<!DOCTYPE html>
<html>
<head>
    <title>简单跨域测试</title>
    <meta charset="UTF-8">
</head>
<body>
    <h1>Gateway跨域测试</h1>
    <button onclick="testCors()">测试跨域请求</button>
    <div id="result"></div>

    <script>
        async function testCors() {
            const resultDiv = document.getElementById('result');
            resultDiv.innerHTML = '正在测试...';
            
            try {
                const response = await fetch('http://localhost:12000/user/getUserById/1', {
                    method: 'GET',
                    headers: {
                        'Content-Type': 'application/json',
                        'Authorization': 'Bearer token123'
                    }
                });
                
                if (response.ok) {
                    const data = await response.json();
                    resultDiv.innerHTML = `
                        <p style="color: green;">✅ 跨域请求成功！</p>
                        <p>用户信息：${JSON.stringify(data, null, 2)}</p>
                    `;
                } else {
                    resultDiv.innerHTML = `
                        <p style="color: red;">❌ 请求失败：${response.status}</p>
                    `;
                }
            } catch (error) {
                resultDiv.innerHTML = `
                    <p style="color: red;">❌ 跨域请求失败：${error.message}</p>
                `;
            }
        }
    </script>
</body>
</html> 